<?php 
 define('PRODUCTS',79);
 define('COLS', 9);
 $count = 0;
 $rows = ceil( PRODUCTS / COLS )  ;
 echo "<table width='50%' 
 align='center'>";
 for($i=1 ; $i<=$rows ; $i++) {
   $color = ($i%2==0)?'red':'green';
   echo "<tr>";
   for($j=1 ; $j<=COLS ;$j++) {
   	$count++;
   	if($count<=PRODUCTS) {
     echo "<td style='background:$color'>
     {$count}</td>";	
	} else {
     echo "<td style='background:$color'>
     &nbsp;</td>";	 		
	}
   }
   echo "</tr>";
 }
 echo "</table>";
 